-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds condition to check XDG_DATA_HOME to set global_dir value #2361
base: devel
Are you sure you want to change the base?
adds condition to check XDG_DATA_HOME to set global_dir value #2361
Conversation
✅ Deploy Preview for dlt-hub-docs canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the contribution :) I have one note, and it would be good to have a test for this. maybe in test_run_context.py
if not os.path.isdir(os.path.join(home, DOT_DLT)): | ||
return os.path.join(os.environ["XDG_DATA_HOME"], "dlt") | ||
else: | ||
warnings.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use logger.warning in our codebase, maybe use that instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you mean dlt.common.logger
, when I import it into run_context.py
the conftest fails:
ImportError while loading conftest 'tests/common/runtime/conftest.py'.
tests/common/runtime/conftest.py:1: in <module>
from tests.utils import preserve_environ
tests/utils.py:43: in <module>
ALL_DESTINATIONS = dlt.config.get("ALL_DESTINATIONS", list) or [
dlt/common/configuration/accessors.py:39: in get
value, _ = self._get_value(field, expected_type)
dlt/common/configuration/accessors.py:74: in _get_value
for provider in self.config_providers:
dlt/common/configuration/accessors.py:104: in config_providers
return [p for p in self._get_providers_from_context()]
dlt/common/configuration/accessors.py:64: in _get_providers_from_context
return Container()[PluggableRunContext].providers.providers
dlt/common/configuration/container.py:67: in __getitem__
item = spec()
dlt/common/configuration/specs/pluggable_run_context.py:90: in __init__
self._plug(run_dir=None)
dlt/common/configuration/specs/pluggable_run_context.py:161: in _plug
m = plugins.manager()
dlt/common/configuration/plugins.py:47: in manager
return Container()[PluginContext].manager
dlt/common/configuration/container.py:67: in __getitem__
item = spec()
dlt/common/configuration/plugins.py:31: in __init__
self.manager.add_hookspecs(run_context)
E AttributeError: 'function' object has no attribute 'get'
Without importing it, the tests run normally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK! let's keep the warn
. When creating a run_context, logger may not be yet available... Let's skip this for now
For the test, for now I have this test passing in def test_context_with_xdg_dir() -> None:
import tempfile
temp_data_home = os.path.join(tempfile.gettempdir(), "test")
os.environ["XDG_DATA_HOME"] = temp_data_home
ctx = PluggableRunContext()
run_context = ctx.context
assert run_context.global_dir == os.path.join(temp_data_home, "dlt")
os.environ.pop("XDG_DATA_HOME") As for the failing CI above, it seems I have to do |
Description
Check for XDG_DATA_HOME env var when setting the global directory for storing pipeline data.
If the variable if set but
~/.dlt
exists, then it is used with a warning raised to move it manually and not break backwards compatibility.Related Issues
Additional Context